<?php
declare (strict_types = 1);

namespace app\admin\controller;

use app\admin\model\OrderStatus;
use think\facade\Db;
use think\facade\Request;
use think\facade\View;

class Order
{
    public function order_list()
    {
        $maxtime = Request::get('maxtime','','trim,htmlspecialchars,strip_tags');
        $mintime = Request::get('mintime','','trim,htmlspecialchars,strip_tags');
        $cid = Request::get('cid','','trim,htmlspecialchars,strip_tags');
        $maxqian = Request::get('maxqian','','trim,htmlspecialchars,strip_tags');
        $minqian = Request::get('minqian','','trim,htmlspecialchars,strip_tags');
        $keywords = Request::get('keywords','','trim,htmlspecialchars,strip_tags');
        $px=Request::get("px",'','trim,htmlspecialchars,strip_tags');
            $fx= '';

        if($px==''){
            $fx = 'desc';
        }elseif ($px=='desc'){
            $fx = "asc";
        }
        $data=[
            'maxtime'=>$maxtime,
            'mintime'=>$mintime,
            'cid'=>$cid,
            'maxqian'=>$maxqian,
            'minqian'=>$minqian,
            'keywords'=>$keywords,
            'px'=>$px
        ];
        $ding = OrderStatus::zhuang();

        $rt = \app\admin\model\Order::ord($data,input('get.'));

//        if($maxtime!="" and $mintime!=""){
//            $list->whereBetweenTime('add_time',$maxtime,$mintime);
//        }elseif($maxtime=="" and $mintime!=""){
//            $list->whereTime('add_time','<=',$mintime);
//        }elseif ($maxtime!="" and $mintime==""){
//            $list->whereTime('add_time','>=',$maxtime);
//        }
//        if($cid!=""){
//            $list->where('status',$cid);
//        }
//        if($maxqian!="" and $minqian!=""){
//            $list->whereBetween('order_amount',"$maxqian,$minqian");
//        }elseif ($maxqian=="" and $minqian!=""){
//            $list->where('order_amount','<=',"$minqian");
//        }elseif ($maxqian!="" and $minqian==""){
//            $list->where('order_amount','>=',"$maxqian");
//        }
//        if($keywords!=""){
//            $list->whereLike('buyer_name',"%$keywords%");
//        }
//        $rt = $list->paginate([
//            'list_rows'=>10,
//
//            'query'=>Request::get(),
//
//        ]);
//        $page = $rt->render();
//        if($rt->isEmpty()){
//            var_dump($rt->isEmpty());
//            View::assign('rt',$rt);
//        }else{
//
//            View::assign('rt',$rt);
//        }
        $arrm=[
            "keywords"=>$keywords,'maxtime'=>$maxtime,'mintime'=>$mintime,'cid'=>$cid,'maxqian'=>$maxqian,'minqian'=>$minqian
        ];
        View::assign('fx',$fx);
//        View::assign('maxtime',$maxtime);
//        View::assign('mintime',$mintime);
        View::assign('ding',$ding);
//        View::assign('maxqian',$maxqian);
//        View::assign('minqian',$minqian);
//        View::assign('keywords',$keywords);
        View::assign('arrm',$arrm);
        View::assign('rt',$rt);
        View::assign($data);
        return View::fetch();
    }
}